package com.jxwifi.cloud.quickcleanserver.mycenter;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bigkoo.pickerview.TimePickerView;
import com.bumptech.glide.Glide;
import com.idroid.utils.MToast;
import com.idroid.widget.LoadDialog;
import com.idroid.widget.Toaster;
import com.jxwifi.cloud.quickcleanserver.R;
import com.jxwifi.cloud.quickcleanserver.app.CleanBasicActivity;
import com.jxwifi.cloud.quickcleanserver.app.UrlPool;
import com.jxwifi.cloud.quickcleanserver.bean.CerProveList;
import com.jxwifi.cloud.quickcleanserver.bean.SystemBean;
import com.jxwifi.cloud.quickcleanserver.bean.UploadBean;
import com.jxwifi.cloud.quickcleanserver.okhttp.AuzHttp;
import com.jxwifi.cloud.quickcleanserver.okhttp.DataJson_Cb;
import com.jxwifi.cloud.quickcleanserver.okhttp.Params;
import com.jxwifi.cloud.quickcleanserver.utils.Constants;
import com.jxwifi.cloud.quickcleanserver.utils.KAlertDialog;
import com.jxwifi.cloud.quickcleanserver.utils.ToastUtils;
import com.photo.PhotoPickerActivity;
import com.upload.BusinessModule;
import com.upload.ImgUpload;
import com.upload.UpLoadListener;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

import static com.jxwifi.cloud.quickcleanserver.mycenter.AuthenticationActivity.MODE_SINGLE;

/**
 * 认证列表
 * Created by Administrator on 2020/8/5.
 */

public class ProveListActivity extends CleanBasicActivity {

    private String TAG = this.getClass().getSimpleName();
    @Bind(R.id.img_daily)
    ImageView img_daily;
    @Bind(R.id.img_reclaim)
    ImageView img_reclaim;
    @Bind(R.id.img_outdoor)
    ImageView img_outdoor;

    private LoadDialog mLoadDialog;
    private List<CerProveList> msystemBean;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cert_list);
        ButterKnife.bind(this);
        openEventBus();
        mLoadDialog = new LoadDialog(this,"");
        initData();
        //initView();
    }

    private void initView() {
            if(msystemBean.size()>0){
                for (int i = 0; i < msystemBean.size(); i++) {
                    if (msystemBean.get(i).getTitle().equals("日常")){
                        img_daily.setVisibility(View.VISIBLE);
                    }else if(msystemBean.get(i).getTitle().equals("开荒")){
                        img_reclaim.setVisibility(View.VISIBLE);
                    }else if(msystemBean.get(i).getTitle().equals("室外")){
                        img_outdoor.setVisibility(View.VISIBLE);
                    }
                }
            }
        mLoadDialog.dismiss();
    }

    @OnClick({R.id.rel_img_back_pressed})
    void clickCK(View v){
        Intent intent = new Intent();
        switch (v.getId()){
            case R.id.rel_img_back_pressed:
                onBackPressed();
                break;
        }
    }

    /**
     * 获取资质认证信息
     */
    public void initData(){
        Params params=new Params();
        AuzHttp.get(UrlPool.GET_CLEANERCERT_PROVELIST,params, new DataJson_Cb() {
            @Override
            public void onSuccess(int code, String data) {
                Log.i(TAG,"initData ==> code = "+code+" data = "+data);
                if (code==0){
                    msystemBean = JSON.parseArray(data, CerProveList.class);
                    Log.i(TAG,"initData ==> msystemBean.size() = "+msystemBean.size());
                    initView();
                }
            }

            @Override
            public void onFailure(int errorCode, String msg) {

                mLoadDialog.dismiss();
                Toast toast =Toast.makeText(mBaseContext, msg, Toast.LENGTH_SHORT);
                ToastUtils.showMyToast(toast,3000);
            }
        },TAG);

    }



}
